import math

fact=math.factorial

def main() :
    n=0
    k=0
    with open("2.in", "r") as f :
        temp=f.readline().split()
        n=int(temp[0])
        k=int(temp[1])
    ans=0
    for i in range(math.ceil(n/2), n+1) :
        ans = ans+(fact(i)//fact(n-i)//fact(2*i-n))*(k-1)**i
    with open("2_bf.out", "w") as f :
        print(ans, file=f)

if __name__=='__main__' :
    main()
